
package com.joyo8.app;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.ServiceConnection;
import android.database.Cursor;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.util.Log;

public class Sms_toyActivity extends Activity {

    private ServiceConnection mServiceConnection = new ServiceConnection() {

        public void onServiceConnected(ComponentName name, IBinder service) {
            // TODO Auto-generated method stub
            Constants.mUtil.logd("dxservice connected");
            mDXService = ((DXService.MyBinder) service).getService();
        }

        public void onServiceDisconnected(ComponentName name) {
            // TODO Auto-generated method stub
        }

    };

    private DXService mDXService;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        /*this.getContentResolver().registerContentObserver(
                // watch sms database changed
                // Telephony.Sms.CONTENT_URI,
                Uri.parse("content://sms/inbox/"), true,
                new SmsContentObserver(new Handler(), getApplicationContext()));*/
        Intent intent = new Intent();
        intent.setClass(getApplicationContext(), DXService.class);
        getApplicationContext().bindService(intent, mServiceConnection, BIND_AUTO_CREATE);

        /*Uri uri = Uri.parse("content://sms/inbox/");
        Cursor cur = managedQuery(uri, null, null, null, null);
        if (cur != null && cur.moveToFirst()) {
            do {
                for (int j = 0; j < cur.getColumnCount(); j++) {
                    String info = "name:" + cur.getColumnName(j) + "=" + cur.getString(j);
                    Constants.mUtil.logd(" => "+info);
                }
            } while (cur.moveToNext());
        }else{
            Constants.mUtil.logd(" fk! sms cursor is null");
        }*/
    }

}
